<!-- Main content -->
<div class="wrapper">
	<div class="fluid">
		<div class="widget grid12" style="margin:0">
			<div class="whead">
				<h6>编辑权限</h6>
				<div class="clear"></div>
			</div>
			
			<form id="role_form" action="<?php echo BASE_URL;?>role/edit/role_id/<?php echo $role['role_id'];?>" method="post">
			<div class="formRow">
				<div class="grid3">
					<label>权限名称 :</label>
					<input type="text" id="role_name" name="role_name" value="<?php echo CHtml::encode($role['role_name']);?>" class="validate[required]" />
				</div>
				
				<div class="clear"></div>
			</div>
			
			<div class="formRow">
				<div class="grid3">
					<label>动作列表 :</label>
				</div>
				<div class="widget">
					<div class="whead">
						<span class="titleIcon" style="position:static;"><input type="checkbox" class="check"></span>
						<h6>系统动作</h6>
						<div class="clear"></div>
					</div>
					<table cellpadding="0" cellspacing="0" width="100%" class="tLight role-table">
						<tbody class="first-td hand">
						<?php foreach ($rights['user_rights'] as $control => $item):?>
							<tr>
								<td class="this-row"><?php echo $item['text'];?></td>
								<?php foreach ($item['items'] as $act => $action):?>
								<?php 
								if ($this->checkRights($rights_list, $control, $act)) {
									$class = 'thisRow';
									$disabled = '';
								} else {
									$class = '';
									$disabled = 'disabled="disabled"';
								}
								?>
								<td class="<?php echo $class;?>"><?php echo $action['text'];?>
									<input type="hidden" name="rights[<?php echo $control;?>][]" value="<?php echo $act;?>" <?php echo $disabled;?> />
								</td>
								<?php endforeach;?>
							</tr>
						<?php endforeach;?>
						</tbody>
					</table>
					<div class="clear"></div>
				</div>
				
				<?php foreach ($module_rights as $module_id => $module): ?>
				<div class="widget">
					<div class="whead">
						<span class="titleIcon" style="position:static;"><input type="checkbox" class="check"></span>
						<h6><?php echo Yii::app()->getModule($module_id)->name;?></h6>
						<div class="clear"></div>
					</div>
					<table cellpadding="0" cellspacing="0" width="100%" class="tLight role-table">
						<tbody class="first-td hand">
						<?php foreach ($module['user_rights'] as $control => $item):?>
							<tr>
								<td class="this-row"><?php echo $item['text'];?></td>
								<?php foreach ($item['items'] as $act => $action):?>
								<?php 
								if ($this->checkRights($rights_list, $control, $act, $module_id)) {
									$class = 'thisRow';
									$disabled = '';
								} else {
									$class = '';
									$disabled = 'disabled="disabled"';
								}
								?>
								<td class="<?php echo $class;?>"><?php echo $action['text'];?>
									<input type="hidden" name="rights[<?php echo $module_id;?>][<?php echo $control;?>][]" value="<?php echo $act;?>" <?php echo $disabled;?> />
								</td>
								<?php endforeach;?>
							</tr>
						<?php endforeach;?>
						</tbody>
					</table>
					<div class="clear"></div>
				</div>
				<?php endforeach;?>
			</div>
			<div class="formRow">
				<input type="submit" value="保存" class="buttonL bBlue formSubmit" />
				<div class="clear"></div>
			</div>
			</form>
		</div>
	</div>
</div>

<?php $this->util->js(array(
	'js/plugins/forms/jquery.validationEngine-zh_CN.js',
	'js/plugins/forms/jquery.validationEngine.js'
));?>
<script type="text/javascript">
$(document).ready(function() {
	$("#role_form").validationEngine({
		ajaxFormValidation: true,
		ajaxFormValidationMethod: 'post',
		onBeforeAjaxFormValidation: function() {
			
		},
		onAjaxFormComplete: function(status, obj, result) {
			show_msg(result);
		}
	});
});
</script>